const { Sequelize } = require('sequelize');

const sequelize = new Sequelize({
    database: 'chat_system',
    username: 'root',
    password: '308803',
    host: 'localhost',
    dialect: 'mysql',
    logging: false,
    pool: {
        max: 5,
        min: 0,
        acquire: 30000,
        idle: 10000
    }
});

// 测试数据库连接
async function testConnection() {
    try {
        await sequelize.authenticate();
        console.log('数据库连接成功。');
    } catch (error) {
        console.error('数据库连接失败:', error);
    }
}

testConnection();

module.exports = sequelize; 